<?php
class MySQL {
	var $host;
	var $user;
	var $passwd;
	var $database;
	function MySQL() {
		$host = "";
		$user = "";
		$passwd = "";
		$database = "";
	}
	function Connect() {
		$conn = MySQL_connect($this->host, $this->user, $this->passwd) or die("Could not connect to $this->host");
		MySQL_select_db($this->database, $conn) or die("Could not switch to database $this->database;");
		return $conn;
	}
	function Close($conn) {
		MySQL_close($conn);
	}

	function Query($queryStr, $conn) {
		$res = MySQL_query($queryStr, $conn) or die("Could not query database");
		return $res;
	}
	function GetRows($res) {
		$rowno = 0;
		$rowno = MySQL_num_rows($res);

		if ($rowno > 0) {
			for ($row = 0; $row < $rowno; $row++) {
				$rows[$row] = MySQL_fetch_row($res);
			}
			return $rows;
		}
	}

	function GetArray($res) {
		$rowno = 0;
		$rowno = MySQL_num_rows($res);

		if ($rowno > 0) {
			for ($row = 0; $row < $rowno; $row++) {
				$rows[$row] = MySQL_fetch_array($res, MYSQL_BOTH);
			}
			return $rows;
		}
	}
	
	function GetRowsNum($res) {
		$rowno = 0;
		$rowno = mysql_num_rows($res);
		return $rowno;
	}
}
?>